home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
logextensions.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
5KB
|
168 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import logging
LOGGING_ENABLED = True
import types
import sys
import threading
from traceback import print_exc
from threading import currentThread
_LogRecord = logging.LogRecord
class LogRecord(_LogRecord):
def __init__(self, *a, **k):
_LogRecord.__init__(self, *a, **k)
self.threadCount = getattr(currentThread(), 'loopcount', 0)
def getMessage(self):
msg = self.msg
if type(msg) not in (unicode, str):
try:
msg = str(self.msg)
except UnicodeError:
msg = repr(self.msg)
except:
None<EXCEPTION MATCH>UnicodeError
None<EXCEPTION MATCH>UnicodeError
if self.args:
try:
msg = msg % self.args
except Exception:
e = None
print >>sys.stdout, self.filename, self.lineno, map(type, self.args), repr(msg), repr(self.args)
return 'Error in log message (%r:%r): msg=%r, args=%r' % (self.filename, self.lineno, msg, self.args)
except:
None<EXCEPTION MATCH>Exception
None<EXCEPTION MATCH>Exception
return msg
logging.LogRecord = LogRecord
class StreamHandler(logging.Handler):
def __init__(self, strm = None):
logging.Handler.__init__(self)
self._stream = strm
self.formatter = None
self.has_stream = True
def stream(self):
if self._stream is None and self.has_stream:
return sys.stderr
elif self.has_stream:
return self._stream
stream = property(stream)
def flush(self):
try:
self.stream.flush()
except:
if self._stream is not None:
self._stream = None
else:
self.has_stream = False
def emit(self, record):
if not self.has_stream:
return None
try:
msg = self.format(record)
fs = '%s\n'
if not hasattr(types, 'UnicodeType'):
self.stream.write(fs % msg)
else:
try:
self.stream.write(fs % msg)
except UnicodeError:
self.stream.write(fs % msg.encode('UTF-8'))
except Exception:
self.has_stream = False
self.flush()
except (KeyboardInterrupt, SystemExit):
raise
except:
self.handleError(record)
logging.StreamHandler = StreamHandler
logging.FileHandler.__bases__ = (StreamHandler,) + logging.FileHandler.__bases__[1:]
def setup_sensitive_logs():
Logger = Logger
import logging
dev = getattr(sys, 'DEV', False)
full_log = getattr(getattr(sys, 'opts', None), 'full_log', False)
nolog = lambda self, *a, **k: pass
for log_type in [
'critical',
'debug',
'error',
'exception',
'fatal',
'info',
'log',
'warn',
'warning']:
def make_sensitive(name):
if dev or full_log:
def sensitive(self, *a, **k):
getattr(self, name)(*a, **k)
else:
sensitive = nolog
return sensitive
func = make_sensitive(log_type)
setattr(Logger, log_type + '_s', func)
setup_sensitive_logs()
if not LOGGING_ENABLED:
class NullRoot(object):
stream = None
setLevel = addHandler = info = (lambda : pass)
class NullLogger(object):
root = NullRoot()
handlers = []
debug = debug_s = info = info_s = warning = error = critical = (lambda : pass)
_null_logger = NullLogger()
class NullManager(object):
def getLogger(self, name):
return _null_logger
_null_manager = NullManager()
NullLogger.manager = _null_manager
logging.Logger = NullLogger